package com.tedu.ivos.geofence.controller;

import com.tedu.ivos.base.response.JsonResult;
import com.tedu.ivos.geofence.pojo.dto.GeofenceParam;
import com.tedu.ivos.geofence.pojo.dto.GeofenceQuery;
import com.tedu.ivos.geofence.pojo.vo.GeofenceVO;
import com.tedu.ivos.geofence.service.GeofenceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@Api(tags = "电子围栏管理")
@RestController
@RequestMapping("/v1/geofence")
public class GeofenceController {

    @Autowired
    GeofenceService geofenceService;

    @ApiOperation(value = "查询电子围栏信息功能")
    @GetMapping("/select")
    public JsonResult selectGeofence(GeofenceQuery geofenceQuery) {
        log.debug("查询电子围栏信息,条件{}:", geofenceQuery);
        List<GeofenceVO> list=geofenceService.selectGeofence(geofenceQuery);
        return JsonResult.ok(list);
    }

    @ApiOperation(value = "修改或保存围栏信息")
    @PostMapping("/save")
    public JsonResult saveGeofence(GeofenceParam geofenceParam){
        log.debug("保存或者修改围栏信息:{}",geofenceParam);
        geofenceService.saveGeofence(geofenceParam);
        return JsonResult.ok();
    }

    @ApiOperation(value = "删除围栏信息")
    @PostMapping("/delete/{id}")
    public JsonResult deleteGeofence(@PathVariable Long id){
        log.debug("删除围栏信息:{}",id);
        geofenceService.deleteGeofence(id);
        return JsonResult.ok();
    }
}
